home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 August / macformat-027.iso / mac / Shareware City / Developers / Oberon⁄F / Text / Docu / Views (.txt) < prev   
Encoding:
Oberon Document  |  1994-06-07  |  11.6 KB  |  269 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Geneva
  16. TextRulers.StdRulerDesc
  17. TextRulers.RulerDesc
  18. TextRulers.StdStyleDesc
  19. TextRulers.StyleDesc
  20. TextRulers.AttributesDesc
  21. Geneva
  22. Geneva
  23. 6.5 TextViews
  24. DEFINITION TextViews;
  25.     IMPORT Models, Views, Containers, TextModels, TextRulers, TextSetters;
  26.     CONST
  27.         show = FALSE; hide = TRUE;
  28.         any = FALSE; focusOnly = TRUE;
  29.     TYPE
  30.         View = POINTER TO ViewDesc;
  31.         ViewDesc = RECORD (Containers.ViewDesc)
  32.             PROCEDURE (v: View) Clone (): View;
  33.             PROCEDURE (v: View) ThisModel (): TextModels.Model;
  34.             PROCEDURE (v: View) DisplayMarks (hide: BOOLEAN);
  35.             PROCEDURE (v: View) HidesMarks (): BOOLEAN;
  36.             PROCEDURE (v: View) SetSetter (setter: TextSetters.Setter);
  37.             PROCEDURE (v: View) ThisSetter (): TextSetters.Setter;
  38.             PROCEDURE (v: View) SetOrigin (org, dy: LONGINT);
  39.             PROCEDURE (v: View) PollOrigin (VAR org, dy: LONGINT);
  40.             PROCEDURE (v: View) SetDefaults (r: TextRulers.Ruler; a: TextModels.Attributes);
  41.             PROCEDURE (v: View) PollDefaults (VAR r: TextRulers.Ruler; VAR a: TextModels.Attributes);
  42.             PROCEDURE (v: View) GetThisLocation (f: Views.Frame; pos: LONGINT; VAR loc: Location);
  43.             PROCEDURE (v: View) GetRange (f: Views.Frame; VAR beg, end: LONGINT);
  44.             PROCEDURE (v: View) ThisPos (f: Views.Frame; x, y: LONGINT): LONGINT;
  45.             PROCEDURE (v: View) ShowRangeIn (f: Views.Frame; beg, end: LONGINT);
  46.             PROCEDURE (v: View) ShowRange (beg, end: LONGINT; focusOnly: BOOLEAN)
  47.         END;
  48.         Directory = POINTER TO DirectoryDesc;
  49.         DirectoryDesc = RECORD
  50.             defAttr-: TextModels.Attributes;
  51.             PROCEDURE (d: Directory) Set (defAttr: TextModels.Attributes);
  52.             PROCEDURE (d: Directory) New (text: TextModels.Model): View;
  53.             PROCEDURE (d: Directory) StdNew () : View
  54.         END;
  55.         Location = RECORD
  56.             start, pos: LONGINT;
  57.             x, y: LONGINT;
  58.             asc, dsc: LONGINT;
  59.             view: Views.View;
  60.             l, t, r, b: LONGINT
  61.         END;
  62.         PositionMsg = RECORD (Models.Message)
  63.             focusOnly: BOOLEAN;
  64.             beg, end: LONGINT
  65.         END;
  66.         ctrlDir-: Containers.Directory;
  67.         dir-, stdDir-: Directory;
  68.     PROCEDURE SetCtrlDir (d: Containers.Directory);
  69.     PROCEDURE SetDir (d: Directory);
  70.     PROCEDURE Focus (): View;
  71.     PROCEDURE FocusText (): TextModels.Model;
  72.     PROCEDURE Deposit;
  73.     PROCEDURE ShowRange (text: TextModels.Model; beg, end: LONGINT; focusOnly: BOOLEAN);
  74.     PROCEDURE ThisRuler (v: View; pos: LONGINT): TextRulers.Ruler;
  75. END TextViews.
  76. TextViews are the standard views for text models as defined in TextModels.
  77. CONST show, hide
  78. Possible arguments to the hide parameter of view.DisplayMarks.
  79. CONST any, focusOnly
  80. Possible arguments to the focusOnly parameter of view.ShowRange.
  81. TYPE View
  82. Interface, Extension
  83. Standard view for text models.
  84. PROCEDURE (v: View) Clone (): View
  85. Default, Extension
  86. Result type is narrowed.
  87. PROCEDURE (v: View) ThisModel (): TextModels.Model
  88. Default, Extension
  89. Result type is narrowed.
  90. PROCEDURE (v: View) DisplayMarks (hide: BOOLEAN)
  91. Interface, [Operation]
  92. Control hiding of hideable views embedded in the displayed text. If hiding is requested, all views that have a preference hideable will be suppressed, i.e. reduced to zero width and zero height. For example, this is used to selectively hide or show rulers in a text.
  93. If v.context # NIL and ~v.context.Normalize(), this is an operation.
  94. v.HidesMarks() = hide
  95. PROCEDURE (v: View) HidesMarks (): BOOLEAN
  96. Interface
  97. Current status: Whether view hides hideable views, or not.
  98. PROCEDURE (v: View) SetSetter (setter: TextSetters.Setter)
  99. Interface, Operation
  100. Attach a setter to the view.
  101. setter # NIL    20
  102. setter.init    21
  103. v.ThisSetter() = setter
  104. PROCEDURE (v: View) ThisSetter (): TextSetters.Setter
  105. Interface
  106. Returns setter currently attached to view.
  107. PROCEDURE (v: View) SetOrigin (org, dy: LONGINT)
  108. Interface, [Operation]
  109. Set the origin and vertical displacement of the view.
  110. If v.context # NIL and ~v.context.Normalize(), this is an operation.
  111. v.ThisModel() # NIL    20
  112. 0 <= org    21
  113. org <= v.ThisModel().Length()    22
  114. dy <= 0    23
  115. org = v.ThisSetter().ThisLine(org)
  116.     v.PollOrigin(o, d): o = org, d = dy
  117. org # v.ThisSetter().ThisLine(org)
  118.     v.PollOrigin(o, d): o = v.ThisSetter().ThisLine(org), d = 0
  119. PROCEDURE (v: View) PollOrigin (VAR org, dy: LONGINT)
  120. Interface
  121. Return origin and vertical displacement of view.
  122. 0 <= org <= v.ThisModel().Length()
  123. dy <= 0
  124. PROCEDURE (v: View) SetDefaults (r: TextRulers.Ruler; a: TextModels.Attributes)
  125. Interface, Operation
  126. Set the default ruler and attributes.
  127. r # NIL    20
  128. r.init    21
  129. a # NIL    22
  130. a.init    23
  131. PROCEDURE (v: View) PollDefaults (VAR r: TextRulers.Ruler; VAR a: TextModels.Attributes)
  132. Interface
  133. Return default ruler and attributes.
  134. PROCEDURE (v: View) GetThisLocation (f: Views.Frame; pos: LONGINT; VAR loc: Location)
  135. Interface
  136. Get the location characteristics of the position pos displayed in frame f. (The frame is required to take decive
  137. dependent character positioning inside words into account.) If pos lies outside view, the next best position inside will be taken.
  138. f # NIL    20
  139. Displayed(f)    21
  140. 0 <= pos    22
  141. pos <= v.ThisModel().Length()    23
  142. loc.view # NIL
  143.     loc.l <= loc.r, loc.t <= loc.b    bounding box of view
  144. PROCEDURE (v: View) GetRect (f: Views.Frame; view: Views.View; VAR l, t, r, b: LONGINT)
  145. Default, Extension
  146. f # NIL    20
  147. Displayed(f)    21
  148. view.context # NIL    22
  149. view.context.ThisModel() = v.ThisModel()    23
  150. Except for performace, equivalent to:
  151.     VAR loc: Location;
  152.     v.GetThisLocation(f, view.context(TextModels.Context).Pos(), loc);
  153.     IF loc.view = view THEN
  154.         l := loc.l; t := loc.t; r := loc.r; b := loc.b
  155.     ELSE
  156.         l := Views.infinite; t := Views.infinite; r := l; b := t
  157. PROCEDURE (v: View) GetRange (f: Views.Frame; VAR beg, end: LONGINT)
  158. Interface
  159. Get the stretch [beg, end) visible in v.
  160. f # NIL    20
  161. Displayed(f)    21
  162. beg = BeginOf(FirstLineVisible(v))
  163. end = EndOf(LastLineVisible(v))
  164. PROCEDURE (v: View) ThisPos (f: Views.Frame; x, y: LONGINT): LONGINT;
  165. Interface
  166. f # NIL    20
  167. Displayed(f)    21
  168. v.GetOrigin(o, d): o <= result <= v.ThisModel().Length()
  169. PROCEDURE (v: View) ShowRangeIn (f: Views.Frame; beg, end: LONGINT);
  170. Interface
  171. If possible, make specified stretch [beg, end) visible in f.
  172. f # NIL    20
  173. Displayed(f)    21
  174. If possible, BeginOf(FirstLineVisible(v)) <= k <= EndOf(LastLineVisible(v)):
  175.     beg = end
  176.         k = beg
  177.     beg < end
  178.         beg <= k < end
  179. PROCEDURE (v: View) ShowRange (beg, end: LONGINT; focusOnly: BOOLEAN);
  180. Interface
  181. Locates a reference frame displaying v and performs v.ShowRangeIn on it. If ~focusOnly, an arbitrary frame will be taken, where a target frame takes precedence over all but a front frame, which takes precedence over all other frames. If focusOnly, only a front (or if none exists, a target) frame is taken as a reference, and no repositioning takes place if neither a target nor a front frame is found.
  182. TYPE Directory
  183. Interface
  184. Directory for views.
  185. defAttr-: TextModels.Attributes
  186. Default attributes, used for initial formatting when typing to an empty text.
  187. PROCEDURE (d: Directory) Set (defAttr: TextModels.Attributes)
  188. Default
  189. Set the default attributes.
  190. defAttr # NIL    20
  191. defAttr.init    21
  192. d.defAttr = defAttr
  193. PROCEDURE (d: Directory) New (text: TextModels.Model): View
  194. Interface
  195. Return a new view displaying text.
  196. PROCEDURE (d: Directory) StdNew () : View
  197. Default
  198. Except for performance, equivalent to:
  199.         RETURN d.New(TextModels.dir.New())
  200. TYPE Location
  201. Characteristics of an element's (i.e. a character's or embedded view's) location in a text view.
  202. start, pos: LONGINT
  203. Start of line and position of location.
  204. x, y: LONGINT
  205. Coordinates of location.
  206. asc, dsc: LONGINT
  207. Line's ascender and descender at location.
  208. view: Views.View
  209. l, t, r, b: LONGINT
  210. If embedded view at location: The view and its bounding box.
  211. TYPE PositionMsg
  212. Message broadcast by ShowRange to request repositioning.
  213. focusOnly: BOOLEAN
  214. Reposition front (or, if none, target) view only.
  215. beg, end: LONGINT
  216. The range requested to become visible.
  217. VAR ctrlDir-: Containers.Directory    stable ctrlDir # NIL
  218. Controller directory object. If installed, this directory object is used by the view directory object to install a controller in a newly created view. Upon initialization, module TextViews tries to load module TextControllers which, if available, in turn installs the standard controller directory object in ctrlDir.
  219. VAR dir-, stdDir-: Directory    dir # NIL, stdDir # NIL, stable stdDir = d
  220. Directory and standard directory objects for views.
  221. PROCEDURE SetCtrlDir (d: Containers.Directory)
  222. Set controller directory object.
  223. d # NIL    20
  224. ctrlDir = d
  225. PROCEDURE SetDir (d: Directory)
  226. Set directory object.
  227. d # NIL    20
  228. dir = d
  229. PROCEDURE Focus (): View
  230. Return focus text view, if one exists.
  231. Except for performace, equivalent to:
  232.     VAR v: Views.View;
  233.     v := Controllers.FocusView();
  234.     IF (v # NIL) & (v IS View) THEN RETURN v(View) ELSE RETURN NIL END
  235. PROCEDURE FocusText (): TextModels.Model
  236. Return focus text, if one exists.
  237. Except for performace, equivalent to:
  238.     VAR v: View;
  239.     v := Focus();
  240.     IF v # NIL THEN RETURN v.ThisModel() ELSE RETURN NIL END
  241. PROCEDURE Deposit
  242. Deposit a default text view in the Views queue.
  243. Except for performace, equivalent to:
  244.     Views.Deposit(dir.StdNew())
  245. PROCEDURE ShowRange (text: TextModels.Model; beg, end: LONGINT;
  246.                                                 focusOnly: BOOLEAN)
  247. For all views v displaying text, issue v.ShowRange(beg, end, focusOnly).
  248. text # NIL    20
  249. Except for performace, equivalent to:
  250.     VAR pm: PositionMsg;
  251.     pm.beg := beg; pm.end := end; pm.focusOnly := focusOnly;
  252.     Models.Broadcast(text, pm)
  253. PROCEDURE ThisRuler (v: View; pos: LONGINT): TextRulers.Ruler
  254. Locate the ruler dominating position pos in the text displayed by v.
  255. v # NIL    20
  256. v.ThisModel() # NIL    21
  257. 0 <= pos    22
  258. pos <= v.ThisModel().Length()    23
  259. Except for performace, equivalent to:
  260.     VAR r: TextRulers.Ruler; a: TextModels.Attributes; rpos: LONGINT;
  261.     v.PollDefaults(r, a); rpos := -1; TextRulers.GetValidRuler(v.ThisModel(), pos, -1, r, rpos);
  262.     RETURN r
  263. TextControllers.StdCtrlDesc
  264. TextControllers.ControllerDesc
  265. Containers.ControllerDesc
  266. Controllers.ControllerDesc
  267. Geneva
  268. Documents.ControllerDesc
  269.